<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let form = {name: undefined, age: undefined, msg: undefined};

    let obj = {name: 'jack', age: 20, msg: 'ok', property1: 'a', property2: 'b', property3: 'c'};


    function copyObj(source, obj) {
        Object.keys(source).forEach(x => {
            source[x] = obj[x]
        })

        return source
    }

    console.log(copyObj(form, obj))
</script>
</body>
</html>
